import {onBeforeMount, onMounted, reactive} from "vue";

export default function () {
  //鼠标打点的数据
  let point = reactive({
    x: 0,
    y: 0
  })

//鼠标打点的方法
  function savePoint(event) {
    point.x = event.pageX
    point.y = event.pageY
  }

  //鼠标打点的生命周期
  onMounted(
    function () {
      window.addEventListener(
        "click",
        savePoint
      )
    }
  ),
    onBeforeMount(
      function () {
        window.removeEventListener(
          "click",
          savePoint
        )
      }
    )
  return point
}
